package web.base.user.dao;

import org.springframework.stereotype.Repository;
import web.base.user.model.UserEntity;
import web.common.jdo.engine.BaseDao;
import web.common.jdo.engine.Expression;

import java.util.List;

/**
 * @author Jin Zheng
 * @since 1.0 2022-01-18
 */
@Repository
public class UserDao extends BaseDao<UserEntity> {
	public UserDao() {
	}

	@Override
	protected void query(Expression exp, UserEntity object, List<Object> paramList) {
		if (object.getState() != null) {
			exp.add("a.state=?");
			paramList.add(object.getState());
		}
		if (object.getMobile() != null && !object.getMobile().isEmpty()) {
			exp.add("a.mobile like ?");
			paramList.add("%" + object.getMobile() + "%");
		}
		if (object.getName() != null && !object.getName().isEmpty()) {
			exp.add("a.name like ?");
			paramList.add("%" + object.getName() + "%");
		}
	}
}
